<%-- 
    Document   : setting
    Created on : 2019-7-17, 14:36:48
    Author     : dusin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    session.setAttribute("url", "../main/bigparams.jsp");
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="../../js/jquery/themes/default/easyui.css" type="text/css" />
        <link rel="stylesheet" href="../../js/jquery/themes/icon.css" type="text/css" />
        <script type="text/javascript" src="../../js/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="../../js/jquery/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="../../js/jquery/locale/easyui-lang-zh_CN.js"></script>
        <script language="JavaScript">
            var factoryCode = '<%=session.getAttribute("factoryCode")%>';
            var companyCode = '<%=session.getAttribute("companyCode")%>';
            function checkComboBoxValue(id) {
                var value = $(id).combobox('getValue');
                var valueField = $(id).combobox("options").valueField;
                var allData = $(id).combobox("getData");
                var result = false;
                if(id=='#companyCode'){
                    if(value=='请选择供应商')return true;
                }else if(id=='#factoryCode'){
                    if(value=='请选择客户')return true;
                }
                for (var i = 0; i < allData.length; i++) {
                    if (value == allData[i][valueField]) {
                        result = true;
                        break;
                    }
                }
                return result;
            }

            $.extend($.fn.validatebox.defaults.rules, {
                selectValueRequired: {
                    validator: function(value, param) {
                        //console.info($(param[0]).find("option:contains('" + value + "')").val());
                        return checkComboBoxValue(param[0]);
                    },
                    message: '该输入项为必选项'
                }
            });
            $(document).ready(function() {
                $('#fm-params').form({
                    url: '../../servlet/web/cargo/SetBigParams',
                    onSubmit: function() {
                        return $(this).form('validate');
                    },
                    success: function(data) {
                        var result = eval('(' + data + ')');
                        $.messager.alert('Info', result.msg, 'info');
                        
                    }
                });
                if(companyCode!=null&&companyCode!=''&&companyCode!='null')
                    $('#companyCode').combobox('setValue',companyCode);
                if(factoryCode!=null&&factoryCode!=''&&factoryCode!='null')
                    $('#factoryCode').combobox('setValue',factoryCode);
            });
            function setParams() {
                $('#fm-params').form('submit');
               
            }

        </script>        

    </head>
    <body>       
        <div id="p" class="easyui-panel" title="大屏参数"
             style="width:500px;height:150px;padding:10px;background:#fafafa;"
             data-options="iconCls:'icon-save',maximized:true">
            <form id="fm-params" method="post" >            
                <div class="fitem">
                    <label>供应商:</label>
                    <select class="easyui-combobox" name="companyCode" id="companyCode" 
                        validType="selectValueRequired['#companyCode']"
                        style="width:250px"
                        data-options="valueField:'code',textField:'name',prompt:'请选择供应商',
                        url:'../../servlet/web/mycompany/Load4Combo',
                        editable:true">                        
                    </select>    
                      
                </div>
                <div class="fitem" class="easyui-validatebox" required="true">
                    <label>客户:</label>
                    <select class="easyui-combobox" name="factoryCode" id="factoryCode" 
                        validType="selectValueRequired['#factoryCode']"
                        style="width:250px"
                        data-options="valueField:'code',textField:'name',prompt:'请选择客户',
                        url:'../../servlet/web/factory/Load4Combo',
                        editable:true">                        
                    </select> 
                </div>            
            </form>
            <div id="form-buttons">
                <a href="#" style="margin-top: 30px;margin-left: 180px;padding-left:30px" class="easyui-linkbutton" iconCls="icon-ok" onclick="setParams()">确定</a>                
            </div>            
        </div>
        <style type="text/css">
            #fm{
                margin:0;
                padding:10px 30px;
            }
            .ftitle{
                font-size:14px;
                font-weight:bold;
                padding:5px 0;
                margin-bottom:10px;
                border-bottom:1px solid #ccc;
            }
            .fitem{
                margin-bottom:5px;
            }
            .fitem label{
                display:inline-block;
                width:80px;
            }
            .fitem input{
                width:160px;
            }
        </style>
    </body>
</html>
